﻿package mortal.common.global
{
    import com.gengine.core.*;
	import extend.php.*;
	import com.gengine.global.*;
	
    import flash.display.*;

    public class ParamsConst extends ClassProxy
    {
        private var _isInit:Boolean = false;
        public var platformCode:String;
        public var platformUserName:String;
        public var username:String;
        public var player_id:int;
        public var userId:int;
        public var server:String;
        public var time:Object;
        public var issm:int;
        public var isAdult:int;
        public var totalOnlineTime:Number;
        public var flag:String;
        public var defaultCamp:int;
        public var defaultSex:int;
        public var roleName:String;
        public var guest:int;
        public var newUser:int = 0;
        public var version:String = "1.0.0.0";
        public var flashVersion:String = "1.0.0.0";
        public var loginIP:String = "192.168.10.91:9500";
        public var gameIP:String;
        public var mainPath:String;
        public var configUrl:String;
        public var createRoleUrl:String = "CreateRole.swf";
        public var gameUrl:String = "MainGame.swf";
        public var password:String;
        public var isConnectionServer:Boolean = true;
        public var dothingUrl:String;
        public var phpID:int;
        public var payUrl:String;
        public var actimUrl:String;
        public var bbsUrl:String;
        public var proctecUrl:String;
        public var xskUrl:String = "http://frxz2.4399.com";
        public var title:String;
        public var gmInfo:String;
        public var randomNameUrl:String;
        public var loginGiftUrl:String;
        public var sDocc:int;
        public var gmHelpUrl:String;
        public var fastUrl:String;
        public var proxyType:String;
        public var favoritesUrl:String;
        public var preloaders:String = "";
        public var libraryUrls:String = "";
        public var isAddFairyland:Boolean;
        public var gameTipsPath:String = "assets/config/gametips.xml";
        public var quickRegisterUrl:String = "http://frmmo1.my4399.com/f2_game/create_plant_user.php";
        public static const DefaultPassWord:String = "123456";
        public static var isPay:Boolean = true;
        private static var _instance:ParamsConst;

        public function ParamsConst()
        {
			super();
			
            if (_instance != null)
            {
                throw new Error(" ParamsConst 单例 ");
            }
        }
		
        public function init(stage:Stage) : void
        {
            var parameters:Object = null;
            if (stage)
            {
                if (this._isInit == false)
                {
                    //parameters = stage.loaderInfo.parameters;
					parameters = myparams;
                    write(parameters);
                    PathConst.mainPath = this.mainPath == null ? ("") : (this.mainPath);
                    this._isInit = true;
                    this.time = new Date(parseFloat(this.time as String) * 1000);
                    this.payUrl = this.payUrl == null ? ("") : (this.payUrl.replace(/#""#/g, "&") + this.username);
                    ParamsConst.isPay = this.sDocc == 1 ? (true) : (false);
                    PHPSender.isCreateRole = (this.newUser == 1);
                    this.setDebugModle(parameters);
                }
            }
            else
            {
                this._isInit = false;
                throw new Error("stage == null");
            }
        }

        private function setDebugModle(data:Object) : void
        {
            if (data.hasOwnProperty("isDebug"))
            {
                if (data.isDebug == true || data.isDebug == "true")
                {
                    Global.isDebugModle = true;
                }
                else
                {
                    Global.isDebugModle = false;
                }
            }
            else
            {
                Global.isDebugModle = false;
            }
            if (data.hasOwnProperty("isAddFairyland"))
            {
                if (data.isAddFairyland == true || data.isAddFairyland == "true")
                {
                    this.isAddFairyland = true;
                }
                else
                {
                    this.isAddFairyland = false;
                }
            }
            else
            {
                this.isAddFairyland = true;
            }
        }

        public static function get instance() : ParamsConst
        {
            if (_instance == null)
            {
                _instance = new ParamsConst;
            }
            return _instance;
        }
    }
}
